package com.ldg.seckill.controller;

import com.alipay.api.AlipayApiException;
import com.ldg.seckill.client.OrderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @Author: Liudao
 * @Date: 2022-10-22-15:51
 * @Description:
 */
@Controller
@RequestMapping("pay")
public class PayController {
    @Autowired
    private OrderClient orderClient;
    /**
     * 1. 返回支付宝的支付页面
     * @param outTradeNo
     * @param session
     * @return
     * @throws AlipayApiException
     */
    @GetMapping("payPage/{outTradeNo}")
    @ResponseBody
    public String pagePage(@PathVariable String outTradeNo, HttpSession session) throws AlipayApiException {
        return orderClient.pay(2, outTradeNo, session);
    }
}
